<?php

namespace App\Http\Controllers;

use App\Models\Cate;
use App\Models\System;
use App\Models\Article;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\View;

class IndexController extends Controller
{
    public function __construct()
    {
        $cates = Cate::orderBy('sort')->get();
        $webInfo = System::first();
        $topArticles = Article::orderBy('created_at', 'desc')->where(['is_top' => 1, 'status' => 1])->limit(10)->get();
        $viewData = [
            'cates' => $cates,
            'webInfo' => $webInfo,
            'topArticles' => $topArticles
        ];
        View::share($viewData);
    }
}
